package com.fan.admin.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;

import javax.sql.DataSource;

/**
 * @author fan
 * @date 2021/2/27
 */
@Configuration
public class DataSourceTransactionConfig {

	@Autowired
	private DataSource dataSource;

	@Bean
	TransactionTemplate getTransactionTemplate() {
		TransactionTemplate transactionTemplate = new TransactionTemplate();
		transactionTemplate.setTransactionManager(new DataSourceTransactionManager(dataSource));
		return transactionTemplate;
	}
}
